package com.banshuibao.bsb_android.activity;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.ImageView;

import com.banshuibao.bsb_android.R;
import com.banshuibao.bsb_android.adapter.MyPageAdapter;
import com.banshuibao.bsb_android.fragment.CaseFragmentOne;
import com.banshuibao.bsb_android.fragment.CaseFragmentThree;
import com.banshuibao.bsb_android.fragment.CaseFragmentTwo;
import com.banshuibao.bsb_android.util.IntentManager;

import java.util.ArrayList;

public class CaseActivity extends BaseActivity implements View.OnClickListener{

    private ImageView back,search;
    private TabLayout tabLayout;
    private ViewPager viewPager;
    private String [] title = {"筹划案例","法院判例","稽查案例"};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_case);
        initView();
    }

    private void initView() {
        back = findViewById(R.id.back_case);
        search = findViewById(R.id.search_case);
        tabLayout = findViewById(R.id.tablayout);
        viewPager = findViewById(R.id.tab_viewpager);
        back.setOnClickListener(this);
        search.setOnClickListener(this);

        ArrayList<Fragment> fragments = new ArrayList<>();
        fragments.add(new CaseFragmentOne());
        fragments.add(new CaseFragmentTwo());
        fragments.add(new CaseFragmentThree());
        MyPageAdapter adapter = new MyPageAdapter(getSupportFragmentManager(),title);
        adapter.setFragments(fragments);
        viewPager.setAdapter(adapter);
        tabLayout.setupWithViewPager(viewPager);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.back_case:
                finish();
                break;
            case R.id.search_case:
                IntentManager.goDataQueryActivity(CaseActivity.this,"case");
                break;
        }
    }
}
